package com.yanqu.road.server.cmd.platform;

import com.yanqu.road.entity.enums.eGamePlayerEventType;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.PlatformActivityProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.GameProtocol;

@Cmd(code = GameProtocol.S_QUESTIONNAIRE_GET_REWARD,desc = "问卷调查领取奖励")
public class QuestionnaireGetRewardCmd extends AbstractCommand {

    private int seconds;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        PlatformActivityProto.GetQuestionnaireActivityRewardReq getQuestionnaireActivityReward = PlatformActivityProto.GetQuestionnaireActivityRewardReq.parseFrom(packet.getBytes());
        seconds = getQuestionnaireActivityReward.getSecond();
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        player.notifyListener(eGamePlayerEventType.QuestionnaireReward.getValue(),seconds);
        PlatformActivityProto.GetQuestionnaireActivityRewardResp.Builder builder = PlatformActivityProto.GetQuestionnaireActivityRewardResp.newBuilder();
        player.sendPacket(ClientProtocol.U_QUESTIONNAIRE_GET_REWARD,builder);

    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
